home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: yang@math.umass.edu (Huayong Yang)
- Newsgroups: comp.lang.c,comp.lang.c.moderated
- Subject: Re: const pointer confusion...
- Date: 24 Mar 1996 11:42:48 -0600
- Organization: UMass/Amherst Dept Math & Stats
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4j41io$nma@solutions.solon.com>
- References: <4j06gm$7oa@solutions.solon.com>
- NNTP-Posting-Host: solutions.solon.com
- X-Newsreader: Tin 1.1 PL362948
-
-
- const int *p and int const *p are the same: a pointer to const integer;
- int * const p means a const pointer to integer. A little program to
- verify it:
-
- int main()
- {
- int a = 10;
- const int *b = &a;
- int const *c = &a;
- int * const d = &a;
- int e = 15;
- b = &e;
- /* WRONG: *b = 20; */
- c = &e;
- /* WRONG: *c = 20; */
- /* WRONG: d = &e; */
- *d = 20;
- return 0;
- }
-
-
- --
- Huayong
-
- WWW home pages: Email:
- http://www.math.umass.edu/~yang yang@math.umass.edu
-